package org.misty.seckill.controller;

import org.misty.seckill.interceptor.AuthorizationInterceptor2;
import org.misty.seckill.service.GoodsService;
import org.misty.seckill.vo.SGoodsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@AuthorizationInterceptor2.IgnoreAuth
@RestController
@RequestMapping("/goods")
public class GoodsController {
  @Autowired
  private GoodsService goodsService;

  @GetMapping("")
  public List<SGoodsVo> list() {
    return goodsService.listSecKills();
  }

  @GetMapping("/{sid:\\d+}")
  public SGoodsVo detail2(@PathVariable("sid") long sid) {
    // TODO redis
    return goodsService.getDetailBySid(sid);
  }
}
